<template>
  <div class="item" v-if="item && item.note" @click.stop="toNoteDetail">
    <div class="img-box">
      <img :src="item.note.image_u||item.note.entity.img" alt="" />
    </div>
    <div class="my-text title">
      {{ item.note.title }}
    </div>
    <div class="user-info">
      <div class="left">
        <div class="user-img">
          <img :src="item.note.author.p" alt="" />
        </div>
        <div class="name">{{item.note.author.n}}</div>
      </div>
      <div class="right">
        {{ item.note.like_count }}
      </div>
    </div>
  </div>
  <!-- 活动type==2 -->
  <div class="item" v-else-if="item && item.activity" @click="$toast.success('功能研发中...')">
    <div class="img-box">
      <img :src="item.activity.image" alt="" />
    </div>
    <div class="my-text title">
      {{ item.activity.title }}
    </div>
    <div class="user-info">
      <div class="left">
        <div class="user-img">
          <img :src="item.activity.author.p" alt="" />
        </div>
        <div class="name">{{item.activity.author.n}}</div>
      </div>
      <div class="right">
        参与
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ["item"],
  methods:{
    toNoteDetail(){
      this.$router.push({
        name:"notedetail",
        params:{
          noteid:this.item.note.id
        }
      })
    },
  },
  created() {
    console.log(this.item);
  },
};
</script>

<style lang="scss" scoped>
.item {
  width: 1.8rem;
  border-radius: 0.1rem;
  overflow: hidden;
  margin-bottom: 0.2rem;
  .img-box {
    width: 100%;
  }
  .title {
    margin: 0.1rem 0;
    font-size: 0.15rem;
    -webkit-line-clamp: 2;
  }
  .user-info{
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.12rem;
    color: var(--text-gray);
    .left{
      flex-grow: 1;
      display: flex;
      align-items: center;
      .user-img{
        width: 0.16rem;
        height: 0.16rem;
        border-radius: 0.08rem;
        overflow: hidden;
        margin-right: 0.05rem;
      }
    }
  }
}
</style>